//
//  HKViewController.swift
//  yihuiwang_mac
//
//  Created by 张衡 on 2020/9/8.
//  Copyright © 2020 1meeting. All rights reserved.
//

import Foundation

class HKViewController: NSViewController {
    override func loadView() {
        let view = NSView.init(frame: NSMakeRect(0, 0, 400, 200))
        view.wantsLayer = true
        view.layer?.backgroundColor = color_dark.cgColor
        self.view = view
    }
    
    override func viewWillAppear() {
        super.viewWillAppear()
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
        self.hk_refactoringWindow()
    }
    
    func hk_refactoringWindow() {
        self.view.window?.isMovableByWindowBackground = true
        self.view.window?.titlebarAppearsTransparent = true
        self.view.window?.titleVisibility = .hidden
        self.view.window?.collectionBehavior = NSWindow.CollectionBehavior.fullScreenPrimary
        
        //暂时解决
        let themeView = self.view.window?.contentView?.superview
        if let titleView  = themeView?.subviews[1] {
            for subview in titleView.subviews.enumerated() {
                if subview.element.isKind(of: NSClassFromString("NSTitlebarView")!) == true {
                    for btn in subview.element.subviews.enumerated(){
                        btn.element.snp.updateConstraints { (make) in
                            make.left.equalTo(btn.offset*(8+2)+0)
                            make.top.equalTo(9)
                        }
                    }
                }
            }
        }
    }
}
